/*
神经元管理器实现
协调神经网络中所有神经元的管理
支持神经元创建、连接和状态同步
*/
#include "Neuron.h"
#include "NeuronManager.h"
#include <memory>
#include <stdexcept>

NeuronManager& NeuronManager::getInstance() {
    static NeuronManager instance;
    return instance;
}
void NeuronManager::addNeuron(std::shared_ptr<Neuron> neuron) {
    if (neurons.find(neuron->getId()) != neurons.end()) {
        throw std::invalid_argument("Neuron with same id already exists");
    }
    neurons[neuron->getId()] = neuron;
}
std::shared_ptr<Neuron> NeuronManager::getNeuronById(int id) {
    if (neurons.find(id) == neurons.end()) {
        throw std::invalid_argument("Neuron with given id does not exist");
    }
    return neurons[id];
}
void NeuronManager::clear() {
    neurons.clear();
}